package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.service.ClassificationService;
import org.springframework.web.bind.annotation.*;


/**
 * 人群分类管理
 */
@RestController
@RequestMapping("/classification")
public class ClassificationController {
    @Reference
    private ClassificationService classificationService;

    /**
     * 人群分类分页查询
     * @param queryPageBean
     * @return
     */
    @PostMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPageBean) {
        return classificationService.findPage(queryPageBean);
    }

    /**
     * 根据id删除人群分类信息
     * @param id
     * @return
     */
    @DeleteMapping("/deleteById")
    public Result deleteById(Integer id) {
        System.out.println(id);
        try {
            classificationService.deleteById(id);
            return new Result(true, "删除人群分类成功！");
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, "删除人群分类失败！");
        }
    }

}
